package main

import (
	"context"
	"fmt"
	"math/rand"
	"time"
)

func main() {
	intChannels := [3]chan int{
		make(chan int, 1),
		make(chan int, 1),
		make(chan int, 1),
	}
	index := rand.Intn(3)
	fmt.Printf("The index :%d\n", index)

	go func() {
		intChannels[index] <- index
	}()

	timeout, cancelFunc := context.WithTimeout(context.Background(), 1*time.Second)
	defer cancelFunc()
	//time.Sleep(time.Second)
	select {
	case <-timeout.Done():
		fmt.Println("sssssssssssss")

	case <-intChannels[0]:
		fmt.Println("The first case is selected")
	case <-intChannels[1]:
		fmt.Println("The second case is selected")
	case <-intChannels[2]:
		fmt.Println("The third case is selected")
	default:
		fmt.Println(" not case is selected")
	}
}
